export const addProduceIntroduce = (editor) => {
    // ------------------------------------------------------------------------------------------------------------
    /*
      产品介绍图文组件
      这里是没使用后端接口渲染的
    */
      const newProduceIntroduce = (editor) => {
        const { Components } = editor;
        Components.addType('newProduceIntroduce', {
          model: {
            defaults: {
              name: 'newProduceIntroduce',
              droppable: false,
              attributes: { class: 'produceIntroduce-card-wrapper' },
              components: [
                {
                  type: 'div',
                  attributes: { class: 'produceIntroduce-card-wrapper' },
                  components: [
                    {
                      type: 'image',
                      attributes: {
                        src: 'https://cdn4.codesign.qq.com/prototypes/2023/08/03/xDP3923q32qn08ZwlKp03/apgsmrtqzvfi3x3v/5c2600c7572af1bf8847061f35b69b1c.png',
                      },
                    },
                    {
                      type: 'div',
                      attributes: { style: 'width: 100%;height: 40%;padding: 10px;' },
                      components: [
                        {
                          type: 'text',
                          attributes: { class: 'produceContent' },
                          content: 'Bentley Descartes三维图像处理软件'
                        },
                        {
                          type: 'div',
                          attributes: { style: 'height: 30%;width: 100%;padding-right:5%;margin-top:10px;display: flex;flex-direction: row-reverse;height: 30%;' },
                          components: [
                            {
                              type: 'text',
                              attributes: { class: 'more', style: 'border-radius: 5px;border: 1px solid lightgray;font-size: 10px;background-color: white;' },
                              content: '了解更多'
                            },
                            {
                              type: 'text',
                              attributes: { class: 'free', style: 'border-radius: 5px;margin-right: 10px;border: 1px solid lightgray;font-size: 10px;' },
                              content: '免费试用'
                            }
                          ]
                        }
                      ]
                    },
                  ],
                },
              ],
              script() {
                var that = document.getElementById(this.attributes.id.value);
                that.getElementsByClassName('more')[0].onclick = function () { alert('了解更多') }
                that.getElementsByClassName('free')[0].onclick = function () { alert('免费试用') }
              },
              styles: `
            .produceIntroduce-card-wrapper {
              border: 1px solid lightgray;width: 200px;height: 200px;background-color:white;color:black
            }
            .produceIntroduce-card-wrapper img{
              width: 100%;height: 60%;
            }
            .produceContent {
              height: 30%;width: 100%;font-size: 10px;
            }
          `,
            },
          },
        });
      };
      newProduceIntroduce(editor);
      editor.BlockManager.add("produceIntroduce", {
        label: "产品单元",
        category: "产品中心组件",
        select: true,
        content: { type: "newProduceIntroduce" },
      });
}